Power Series Plots
Graphs Using Truncated Series Approximations
Here are some examples of graphs of functions defined by power series using finite series to approximate.
> | with(plots): |
Warning, the name changecoords has been redefined
> | Sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30); |
> | plot(sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3); |
> | Sum(((-1)^n)*(x^(2*n+1))/(2*n+2)!,n=0..30); |
> | plot(sum(((-1)^n)*(x^(2*n+1))/(2*n+2)!,n=0..30),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3); |
> | Sum(((-1)^n)*(x^(2*n))/(2*n+1)!,n=0..30); |
> | plot(sum(((-1)^n)*(x^(2*n))/(2*n+1)!,n=0..30),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3); |
Below I recreate the first example above and compare it to sin(x). We cannot visually distinguish between them.
> | SineSeries:=plot(sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3): |
> | SineGraph:=plot(sin(x),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3,color=blue): |
> | display(SineSeries,SineGraph); |
It takes a much wider window to see any difference between the two graphs.
> | SineSeries2:=plot(sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30),x=-9*Pi..9*Pi,y=-2..2,thickness=3,numpoints=2500): |
> | SineGraph2:=plot(sin(x),x=-9*Pi..9*Pi,y=-2..2,thickness=3,color=blue): |
> | display(SineSeries2,SineGraph2); |
If we add more terms to the sine series we are again not able to visually distinguish between the two graphs over the interval pictured.
> | SineSeries3:=plot(sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..40),x=-9*Pi..9*Pi,y=-2..2,thickness=3,numpoints=2500): |
> | SineGraph3:=plot(sin(x),x=-9*Pi..9*Pi,y=-2..2,thickness=3,color=blue): |
> | display(SineSeries3,SineGraph3); |
This time I will give a function a name and compute some values.
> | Sine30:=sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30): |
> | eval(Sine30,x=1); |
> | evalf(%); |
> | sin(1.0); |
> | eval(Sine30,x=20); |
> | evalf(%); |
> | sin(20.0); |
Here is another way we could give a name to our function defined by a series and use it.
> | Sine30b:=x->sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30); |
> | Sine30b(10.0); |
> | sin(10.0); |
> | plot(Sine30b(x),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3); |
Here is another function defined by a power series again approximated using only the first 31 terms.
> | WhatIsIt:=x->sum(((-1)^n)*(n^2)*(x^n)/(2*n)!,n=0..30); |
> | WhatIsIt(2.0); |
> | WhatIsIt2:=x->sum(((-1)^n)*(n^2)*(x^n)/(2*n)!,n=0..50); |
> | WhatIsIt2(2.0); |
It looks like WhatIsIt is a pretty accurate approximation to the corresponding infinite series at x = 2.
> | (31^2)*(20.0^31)/(2*31)!; |
We can tell that WhatIsIt is an accurate representation of the corresponding infinite series over the interval [0,20] since the number above is so close to zero. Thus we can graph WhatIsIt over the interval [0,20] and consider the graph an accurate representation of the function defined by the corresponging infinite series.
> | plot(WhatIsIt(x),x=0..20,y=-1..4,thickness=3); |
In the graphs below we might be less confident about the accuracy of WhatIsIt in approximating an infinite series over the portion of the interval where x is negative. The graphs probably are accurate based on the computations below them but why might we be less confident?
> | plot(WhatIsIt(x),x=-10..10,y=-10..50,thickness=3); |
> | plot(WhatIsIt(x),x=-20..20,y=-10..300,thickness=3); |
> | WhatIsIt(-20.0); |
> | WhatIsIt2(-20.0); |
Here is an approximation to a function defined by a power series that has a finite interval of convergence.
> | FiniteInterval:=x->sum(((-1)^n)*((x/2)^n)/(2*n),n=1..30); |
The corresponding infinite series would converge over the interval (-2,2]. The convergence would be very slow close to -2 and 2.
> | FiniteInterval2:=x->sum(((-1)^n)*((x/2)^n)/(2*n),n=1..50); |
> | FiniteInterval(0.5); |
> | FiniteInterval2(0.5); |
> | FiniteInterval(1.0); |
> | FiniteInterval2(1.0); |
> | FiniteInterval(1.5); |
> | FiniteInterval2(1.5); |
> | FiniteInterval(1.9); |
> | FiniteInterval2(1.9); |
> | FiniteInterval(1.99); |
> | FiniteInterval2(1.99); |
> | FiniteInterval(-1.99); |
> | FiniteInterval2(-1.99); |
The accuracy in approximating the corresponding infinite series becomes more questionable close to the ends of the interval of convergence. Why does it appear to be more inaccurate at the negative end?
> | FIplot:=plot(FiniteInterval(x),x=-2..2,y=-3..3,thickness=3): |
> | FI2plot:=plot(FiniteInterval2(x),x=-2..2,y=-3..3,thickness=3,color=blue): |
> | display(FIplot,FI2plot); |
> |
> | FIplotb:=plot(FiniteInterval(x),x=-3..3,y=-10..10,thickness=3,numpoints=2500): |
> | FI2plotb:=plot(FiniteInterval2(x),x=-3..3,y=-10..10,thickness=3,color=blue,numpoints=2500): |
> | display(FIplotb,FI2plotb); |
> | FIplotb:=plot(FiniteInterval(x),x=-3..3,y=-1000..1000,thickness=3,numpoints=2500): |
> | FI2plotb:=plot(FiniteInterval2(x),x=-3..3,y=-1000..1000,thickness=3,color=blue,numpoints=2500): |
> | display(FIplotb,FI2plotb); |
Since the corresponding infinite series diverges outside the interval (-2,2] the graphs of the finite series above are useless as approximations of the infinite series outside this interval.